<?php
check_admin_referer('fts-urlshortener');

//main values
$urlserviceenable = $options['urlserviceenable'];
$urlservice = $options['urlservice'];
$urlautogen = $options['urlautogen'];

//tweet
$tweet = $options['tweet'];
$tweeted = get_post_meta($postid, 'tweet', true);

//post
$postid = $post->ID;

//shorturl
$shorturl = get_post_meta($postid, 'shorturl', true);
if(empty($shorturl)){$shorturl = get_post_meta($postid, 'short_url', true);}

//posted info
$posttype = $_POST['post_type'];
$manualgen = $_POST['get-shortlink'];
$posttweet = $_POST['post-tweet'];

if (empty(shorturl)){
	if ($urlserviceenable == 'yes' && $urlservice != 'none'){
		if ($urlautogen == 'yes'){
			switch ($tweet){
				case 'auto': $this->url_logic($postid, $posttype, true, false); break;
				case 'manual': $this->url_logic($postid, $posttype, false, false); break;
				default: break;
			}
		}elseif($manualgen == 'Enabled') {
			switch ($tweet){
				case 'auto': $this->url_logic($postid, $posttype, true, false); break;
				case 'manual': $this->url_logic($postid, $posttype, false, false); break;
				default: break;
			}
		}
	}
} elseif(empty($tweeted) && !empty($posttweet)){
	$this->tweet_logic($postid, $shorturl);
}
?>